package net.flyinggroup.si.integration;

import net.flyinggroup.si.model.Cargo;
import org.springframework.integration.annotation.Filter;
import org.springframework.integration.annotation.MessageEndpoint;

@MessageEndpoint
public class CargoFilter {
    private static final long CARGO_WEIGHT_LIMIT = 1_000;

    @Filter(inputChannel = "cargoSplitterOutputChannel", outputChannel = "cargoFilterOutputChannel", discardChannel = "cargoFilterDiscardChannel")
    public boolean filterIfCargoWeightExceedLimit(Cargo cargo) {
        return cargo.getWeight() <= CARGO_WEIGHT_LIMIT;
    }
}
